<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>测试文件</title>
    <style>
        #test {
            /*准备一个长200px 宽200px的div，背景设置成黄色*/
            width: 200px;
            height: 200px;
            background-color: #FC0;
            /*下面是核心代码*/
            margin: auto;
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
        }
    </style>
</head>

<body>
    <div id="test"> </div>
</body>

</html>